import MatterManager from "../../managers/MatterManager";
import MatterBody from "./MatterBody";
import GlobalEvent from "../../global/GlobalEvent";

export default class SnowMan1 extends MatterBody {


    /** @prop {name:width, tips:"宽度", type:Int, default:0}*/
    public width: number = 150;
    /** @prop {name:height, tips:"高度", type:Int, default:0}*/
    public height: number = 100;

    /** @prop {name:x, tips:"x坐标", type:Int, default:0}*/
    public x: number;
    /** @prop {name:x, tips:"y坐标", type:Int, default:0}*/
    public y: number;
    /** @prop {name:restitution, tips:"弹力系数", type:Int, default:0}*/
    public restitution: number;
    /** @prop {name:friction, tips:"摩擦力", type:Int, default:0}*/
    public friction: number;
    /** @prop {name:frictionStatic, tips:"静态摩擦力", type:Int, default:0}*/
    public frictionStatic: number;
    /** @prop {name:frictionAir, tips:"空气阻力", type:Int, default:0}*/
    public frictionAir: number;
    /** @prop {name:isStatic, tips:"是否是静止的", type:Bool, default:false}*/


    constructor() { super(); }

    public speed: number = 5;
    public angle = 0;

    public isRebound = false;
    public isMove = false;

    realOwner: Laya.Sprite;

    snowBall: any;

    onEnable(): void {
        let owner = this.owner as Laya.Sprite;
        this.realOwner = owner;
        this.body = this.matter.Bodies.rectangle(owner.x, owner.y, this.width, this.height, {
            isStatic: false,
            friction: 0,
            frictionStatic: 0,
            frictionAir: 0
        });
        this.addToWorld();
        super.onEnable();
    }

    onUpdate() {
        this.setPosition(this.realOwner.x, this.realOwner.y);
    }

    public onCollision(event) {
        console.log('block crash...');
    }


    public startMove() {
        this.isMove = true;
    }

    public stopMove() {
        this.isMove = false;
        this.setVelocity(0, 0);
    }
    onDisable(): void {

    }

}